//
//  MineMessViewController.m
//  Mahjong
//
//  Created by KING on 16/9/19.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "MineMessViewController.h"
#import "Header.h"
@interface MineMessViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *tel;
@end

@implementation MineMessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.myTableView.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];
    [self.view addSubview:self.myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
//    [self createButton];
    
    self.navigationItem.title = @"联系人";
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
    backItem.tintColor = [UIColor grayColor];
    self.navigationItem.leftBarButtonItem = backItem;
   
    [self create];
}
-(void)create{
//http://api03.m0571.com/WebJson.aspx?book=MemberDetail&userid=用户ID
    [AppTools createAFN:[NSString stringWithFormat:@"http://api03.m0571.com/WebJson.aspx?book=MemberDetail&userid=%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"userid"]] success:^(id result) {
        NSLog(@"%@",[result[0] objectForKey:@"describe"]);
        NSDictionary *dic = [result[0] objectForKey:@"date"];
        self.name = [dic objectForKey:@"name"];
        self.tel = [dic objectForKey:@"tel"];
        [self.myTableView reloadData];
    } error:^(NSError *error) {
        
        
    }];
   

}
- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createButton{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, SCREENH_HEIGHT-40, SCREEN_WIDTH, 40);
    button.backgroundColor = [UIColor redColor];
    [button setTitle:@"退出登录" forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(disAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)disAction:(UIButton *)btn{
//    AddPhoneViewController *add = [[AddPhoneViewController alloc] init];
//    [self.navigationController pushViewController:add animated:YES];
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
            
            cell.textLabel.text = @"联系人";

            UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH-30, 20)];
            la.textAlignment = NSTextAlignmentRight;
            la.text = self.name;
            [cell.contentView addSubview:la];
            return cell;
        }
    if (indexPath.row == 1) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
        
        
        cell.textLabel.text = @"联系电话";

        
        UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH-30, 20)];
        la.textAlignment = NSTextAlignmentRight;
        la.text = self.tel;
        [cell.contentView addSubview:la];
        return cell;
    }
    if (indexPath.row == 2) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
        
        
        cell.textLabel.text = @"职位";

        
        UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH-10, 20)];
        la.textAlignment = NSTextAlignmentRight;
        la.text = @"经理  ";
        [cell.contentView addSubview:la];
        return cell;
    }
    else{
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
        
        
        cell.textLabel.text = @"年龄";
        
        
        UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH-10, 20)];
        la.textAlignment = NSTextAlignmentRight;
        la.text = @"14  ";
        [cell.contentView addSubview:la];
        return cell;
    }

    
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
